package com.superm.controller;

import com.superm.entity.RolePoJo;
import com.superm.service.EmpDutiesService;
import com.superm.service.impl.EmpDutiesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/empDuties")
public class EmpDutiesController {


    @Autowired
    private EmpDutiesService empDutiesService;
    /**
     * 向用户角色关系表添加信息
     * @return
     */
    @RequestMapping("/addempRole")
    @ResponseBody
    public Map<String,Object> addempRole(@RequestParam("listRole[]") Integer[] listRole, @RequestParam("eId") int eId) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", "0");
        if (empDutiesService.addEmpRole(listRole, eId) > 0) {
            map.put("success", true);
            map.put("msg", "添加成功!");
        }
        return  map;
    }
    /**
     * 删除用户角色信息
     * @param listRole
     * @param eId
     * @return
     */
    @RequestMapping("/deleteEmpRole")
    @ResponseBody
    public Map<String,Object> deleteEmpRole(@RequestParam("listRole[]") Integer[] listRole, @RequestParam("eId") int eId) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", "0");
        if (empDutiesService.deleteEmpRole(listRole, eId) > 0) {
            map.put("success", true);
            map.put("msg", "移除成功!");
        }else {
            System.out.println("Ddd");
        }
        return  map;
    }
}
